package course;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.microsoft.sqlserver.jdbc.*;

public class DBconn{
	//String connStr="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Foperation";
	String url="jdbc:sqlserver://localhost:1433;DatabaseName=Foperation";
	String userName="sa";  
	  String userPwd="wmz12580"; 
	ResultSet rs=null;
	public DBconn() {
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
		}catch(java.lang.Exception e) {
			System.err.println("DBconn():"+e.getMessage());
		}
	}
	public ResultSet executeQuery(String sql) {
		rs=null;
		try {
			Connection conn=DriverManager.getConnection(url,userName,userPwd);
			Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			rs=stmt.executeQuery(sql);
		}catch (SQLException e) {
			System.err.println("aq.executeQuery:"+e.getMessage());
		}
		return rs;
	}

	
}
